stset time if year>1990 & year<2006, id(sn) failure(year_25death)
//Kaplan-Meier graph
sts

sort sno year
//Model 1
streg dist_nat_gap_civil dist_nat_gap_criminal, cluster(sn) d(w) nohr
generate sample = e(sample) 
test

test dist_nat_gap_civil =0
test dist_nat_gap_criminal =0

//Model 2
streg dist_nat_gap_civil dist_nat_gap_criminal litrate_1991_2001_GAP road_density_GAP lifeexp_1990_2011_GAP  percent_votes1991_1999_GAP if sample ==1, cluster(sn) d(w) nohr
test

test dist_nat_gap_civil =0
test dist_nat_gap_criminal =0

//Model 3
streg dist_nat_gap_civil dist_nat_gap_criminal litrate_1991_2001_GAP road_density_GAP lifeexp_1990_2011_GAP  percent_votes1991_1999_GAP cast_eth_fract ln_pop ln_abs_total2001 ///
if sample ==1, cluster(sn) d(w) nohr
test

test dist_nat_gap_civil =0
test dist_nat_gap_criminal =0

//Model 4
streg dist_nat_gap_civil dist_nat_gap_criminal litrate_1991_2001_GAP road_density_GAP lifeexp_1990_2011_GAP  percent_votes1991_1999_GAP  ln_pop ln_abs_total2001 ///
hilli_region mountain_region  if sample ==1, cluster(sn) d(w) nohr
test
test dist_nat_gap_civil =0
test dist_nat_gap_criminal =0

//Model 5
streg dist_nat_gap_civil dist_nat_gap_criminal litrate_1991_2001_GAP road_density_GAP lifeexp_1990_2011_GAP  percent_votes1991_1999_GAP  ln_pop ln_abs_total2001 ///
 region_east region_mid region_west region_farwest  if sample ==1, cluster(sn) d(w) nohr
test
test dist_nat_gap_civil =0
test dist_nat_gap_criminal =0

//Model 6
streg dist_nat_gap_civil dist_nat_gap_criminal litrate_1991_2001_GAP road_density_GAP lifeexp_1990_2011_GAP  percent_votes1991_1999_GAP  ln_pop ln_abs_total2001 ///
cast_eth_fract region_east region_mid region_west region_farwest hilli_region mountain_region if sample ==1, cluster(sn) d(w) nohr
test
test dist_nat_gap_civil =0
test dist_nat_gap_criminal =0

//sum dist_nat_gap_civil dist_nat_gap_criminal if sample==1

//display -6.350737 -87.62705
//-93.977787
//display -6.350737+87.62705
//81.276313
//One standard deviation below and above mean

stcurve, survival at1(dist_nat_gap_civil=-93.977787)at2(dist_nat_gap_civil=81.276313)

//display -2.72684 -40.40115
//-43.12799

//display -2.72684 + 40.40115
//37.67431

stcurve, survival at1(dist_nat_gap_criminal=-43.12799) at2(dist_nat_gap_criminal=37.67431)

pwcorr dist_nat_gap_civil dist_nat_gap_criminal litrate_1991_2001_GAP road_density_GAP lifeexp_1990_2011_GAP  percent_votes1991_1999_GAP cast_eth_fract ln_pop ln_abs_total2001 ///
hilli_region mountain_region  region_east region_mid region_west region_farwest _d if sample ==1

sum dist_nat_gap_civil dist_nat_gap_criminal litrate_1991_2001_GAP road_density_GAP lifeexp_1990_2011_GAP  percent_votes1991_1999_GAP cast_eth_fract ln_pop ln_abs_total2001 ///
hilli_region mountain_region  region_east region_mid region_west region_farwest _d if sample ==1

graph matrix dist_nat_gap_civil dist_nat_gap_criminal litrate_1991_2001_GAP road_density_GAP lifeexp_1990_2011_GAP  percent_votes1991_1999_GAP cast_eth_fract ln_pop ln_abs_total2001 ///
hilli_region mountain_region  region_east region_mid region_west region_farwest _d  if sample ==1, half  

collin _d dist_nat_gap_civil dist_nat_gap_criminal litrate_1991_2001_GAP road_density_GAP lifeexp_1990_2011_GAP  percent_votes1991_1999_GAP cast_eth_fract ln_pop ln_abs_total2001 ///
hilli_region mountain_region  region_east region_mid region_west region_farwest if sample ==1



//Alternative Model Specificaiton _d as dependent variable


//Model 4 Logit
xtlogit _d dist_nat_gap_civil dist_nat_gap_criminal litrate_1991_2001_GAP road_density_GAP lifeexp_1990_2011_GAP  percent_votes1991_1999_GAP  ln_pop ln_abs_total2001 ///
 hilli_region mountain_region  if sample ==1, vce(robust)
 test

 //Model 5 Logit
 xtlogit _d dist_nat_gap_civil dist_nat_gap_criminal litrate_1991_2001_GAP road_density_GAP lifeexp_1990_2011_GAP  percent_votes1991_1999_GAP  ln_pop ln_abs_total2001 ///
 region_east region_mid region_west region_farwest  if sample ==1, vce(robust)
 test

//Model 6 Logit
xtlogit _d dist_nat_gap_civil dist_nat_gap_criminal litrate_1991_2001_GAP road_density_GAP lifeexp_1990_2011_GAP  percent_votes1991_1999_GAP  ln_pop ln_abs_total2001 ///
cast_eth_fract region_east region_mid region_west region_farwest hilli_region mountain_region if sample ==1, vce(robust)
test

//Logit margin graph
gen MYVAR = dist_nat_gap_civil
xtlogit _d MYVAR dist_nat_gap_criminal litrate_1991_2001_GAP road_density_GAP lifeexp_1990_2011_GAP  percent_votes1991_1999_GAP  ln_pop ln_abs_total2001 ///
cast_eth_fract region_east region_mid region_west region_farwest hilli_region mountain_region if sample ==1, vce(robust)
margins, atmeans at(MYVAR=(-200(20)200)) saving(file1, replace)

drop MYVAR
gen MYVAR = dist_nat_gap_criminal
xtlogit _d dist_nat_gap_civil MYVAR  litrate_1991_2001_GAP road_density_GAP lifeexp_1990_2011_GAP  percent_votes1991_1999_GAP  ln_pop ln_abs_total2001 ///
cast_eth_fract region_east region_mid region_west region_farwest hilli_region mountain_region if sample ==1, vce(robust)

margins, atmeans at(MYVAR=(-200(20)200)) saving(file2, replace)
 
combomarginsplot file1 file2, labels("Change in civil cases" "Change in criminal cases") xtitle("")

drop MYVAR

//Model 4 probit
xtprobit _d dist_nat_gap_civil dist_nat_gap_criminal litrate_1991_2001_GAP road_density_GAP lifeexp_1990_2011_GAP  percent_votes1991_1999_GAP  ln_pop ln_abs_total2001 ///
 hilli_region mountain_region  if sample ==1, vce(robust)
 test
 //Model 5 probit
 xtprobit _d dist_nat_gap_civil dist_nat_gap_criminal litrate_1991_2001_GAP road_density_GAP lifeexp_1990_2011_GAP  percent_votes1991_1999_GAP  ln_pop ln_abs_total2001 ///
 region_east region_mid region_west region_farwest  if sample ==1, vce(robust)
 test
//Model 6 Probit
xtprobit _d dist_nat_gap_civil dist_nat_gap_criminal litrate_1991_2001_GAP road_density_GAP lifeexp_1990_2011_GAP  percent_votes1991_1999_GAP  ln_pop ln_abs_total2001 ///
cast_eth_fract region_east region_mid region_west region_farwest hilli_region mountain_region if sample ==1, vce(robust)
 test
 
//Model Selection Statistics
 //COX
 
 //Model 1
stcox dist_nat_gap_civil dist_nat_gap_criminal if sample ==1, cluster (sn)
estat ic
// Model 2
 
stcox dist_nat_gap_civil dist_nat_gap_criminal litrate_1991_2001_GAP road_density_GAP lifeexp_1990_2011_GAP  percent_votes1991_1999_GAP if sample ==1, cluster (sn)
estat ic
 //Model 3
stcox dist_nat_gap_civil dist_nat_gap_criminal litrate_1991_2001_GAP road_density_GAP lifeexp_1990_2011_GAP  percent_votes1991_1999_GAP cast_eth_fract ln_pop ln_abs_total2001 if sample ==1, cluster(sn)
estat ic
//Model 4
stcox dist_nat_gap_civil dist_nat_gap_criminal litrate_1991_2001_GAP road_density_GAP lifeexp_1990_2011_GAP  percent_votes1991_1999_GAP  ln_pop ln_abs_total2001 ///
hilli_region mountain_region  if sample ==1, cluster(sn)  
estat ic

//Model 5
stcox dist_nat_gap_civil dist_nat_gap_criminal litrate_1991_2001_GAP road_density_GAP lifeexp_1990_2011_GAP  percent_votes1991_1999_GAP  ln_pop ln_abs_total2001 ///
 region_east region_mid region_west region_farwest  if sample ==1, cluster(sn) 
estat ic

//Model 6
stcox dist_nat_gap_civil dist_nat_gap_criminal litrate_1991_2001_GAP road_density_GAP lifeexp_1990_2011_GAP  percent_votes1991_1999_GAP  ln_pop ln_abs_total2001 	///
cast_eth_fract region_east region_mid region_west region_farwest hilli_region mountain_region if sample ==1, cluster(sn)  
 
 estat ic
 //Weibull
 //Model 1
streg dist_nat_gap_civil dist_nat_gap_criminal, cluster(sn) d(w) nohr
estat ic

//Model 2
streg dist_nat_gap_civil dist_nat_gap_criminal litrate_1991_2001_GAP road_density_GAP lifeexp_1990_2011_GAP  percent_votes1991_1999_GAP if sample ==1, cluster(sn) d(w) nohr
estat ic

//Model 3
streg dist_nat_gap_civil dist_nat_gap_criminal litrate_1991_2001_GAP road_density_GAP lifeexp_1990_2011_GAP  percent_votes1991_1999_GAP cast_eth_fract ln_pop ln_abs_total2001 ///
if sample ==1, cluster(sn) d(w) nohr
estat ic
 
//Model 4
 streg dist_nat_gap_civil dist_nat_gap_criminal litrate_1991_2001_GAP road_density_GAP lifeexp_1990_2011_GAP  percent_votes1991_1999_GAP  ln_pop ln_abs_total2001 ///
hilli_region mountain_region  if sample ==1, cluster(sn) d(w) nohr 
estat ic
//Model 5
streg dist_nat_gap_civil dist_nat_gap_criminal litrate_1991_2001_GAP road_density_GAP lifeexp_1990_2011_GAP  percent_votes1991_1999_GAP  ln_pop ln_abs_total2001 ///
 region_east region_mid region_west region_farwest  if sample ==1, cluster(sn) d(w) nohr
 estat ic
 
//Model 6
streg dist_nat_gap_civil dist_nat_gap_criminal litrate_1991_2001_GAP road_density_GAP lifeexp_1990_2011_GAP  percent_votes1991_1999_GAP  ln_pop ln_abs_total2001 	///
cast_eth_fract region_east region_mid region_west region_farwest hilli_region mountain_region if sample ==1, cluster(sn) d(w) nohr  
estat ic
 
 //LogNormal
  //Model 1
streg dist_nat_gap_civil dist_nat_gap_criminal, cluster(sn) d(ln) 
estat ic

//Model 2
streg dist_nat_gap_civil dist_nat_gap_criminal litrate_1991_2001_GAP road_density_GAP lifeexp_1990_2011_GAP  percent_votes1991_1999_GAP if sample ==1, cluster(sn) d(ln) hr
estat ic

//Model 3
streg dist_nat_gap_civil dist_nat_gap_criminal litrate_1991_2001_GAP road_density_GAP lifeexp_1990_2011_GAP  percent_votes1991_1999_GAP cast_eth_fract ln_pop ln_abs_total2001 ///
if sample ==1, cluster(sn) d(ln) 
estat ic
 //Model 4
 streg dist_nat_gap_civil dist_nat_gap_criminal litrate_1991_2001_GAP road_density_GAP lifeexp_1990_2011_GAP  percent_votes1991_1999_GAP  ln_pop ln_abs_total2001 ///
hilli_region mountain_region  if sample ==1, cluster(sn) d(ln) 
estat ic
//Model 5
streg dist_nat_gap_civil dist_nat_gap_criminal litrate_1991_2001_GAP road_density_GAP lifeexp_1990_2011_GAP  percent_votes1991_1999_GAP  ln_pop ln_abs_total2001 ///
 region_east region_mid region_west region_farwest  if sample ==1, cluster(sn) d(ln) 
 estat ic
 
 streg dist_nat_gap_civil dist_nat_gap_criminal litrate_1991_2001_GAP road_density_GAP lifeexp_1990_2011_GAP  percent_votes1991_1999_GAP  ln_pop ln_abs_total2001 	///
cast_eth_fract region_east region_mid region_west region_farwest hilli_region mountain_region if sample ==1, cluster(sn) d(ln) 
 estat ic
 
 //LogLogistic
  //Model 1
streg dist_nat_gap_civil dist_nat_gap_criminal, cluster(sn) d(ll)  
estat ic

//Model 2
streg dist_nat_gap_civil dist_nat_gap_criminal litrate_1991_2001_GAP road_density_GAP lifeexp_1990_2011_GAP  percent_votes1991_1999_GAP if sample ==1, cluster(sn) d(ll) 
estat ic

//Model 3
streg dist_nat_gap_civil dist_nat_gap_criminal litrate_1991_2001_GAP road_density_GAP lifeexp_1990_2011_GAP  percent_votes1991_1999_GAP cast_eth_fract ln_pop ln_abs_total2001 ///
if sample ==1, cluster(sn) d(ll)  
estat ic
 //Model 4
 streg dist_nat_gap_civil dist_nat_gap_criminal litrate_1991_2001_GAP road_density_GAP lifeexp_1990_2011_GAP  percent_votes1991_1999_GAP  ln_pop ln_abs_total2001 ///
hilli_region mountain_region  if sample ==1, cluster(sn) d(ll)  
estat ic
//Model 5
streg dist_nat_gap_civil dist_nat_gap_criminal litrate_1991_2001_GAP road_density_GAP lifeexp_1990_2011_GAP  percent_votes1991_1999_GAP  ln_pop ln_abs_total2001 ///
 region_east region_mid region_west region_farwest  if sample ==1, cluster(sn) d(ll)  
 estat ic
 
 //Model 6
 streg dist_nat_gap_civil dist_nat_gap_criminal litrate_1991_2001_GAP road_density_GAP lifeexp_1990_2011_GAP  percent_votes1991_1999_GAP  ln_pop ln_abs_total2001 	///
cast_eth_fract region_east region_mid region_west region_farwest hilli_region mountain_region if sample ==1, cluster(sn) d(ll)   
estat ic
 
 ///Expnential 
 
  //Model 1
streg dist_nat_gap_civil dist_nat_gap_criminal, cluster(sn) d(e) nohr
estat ic

//Model 2
streg dist_nat_gap_civil dist_nat_gap_criminal litrate_1991_2001_GAP road_density_GAP lifeexp_1990_2011_GAP  percent_votes1991_1999_GAP if sample ==1, cluster(sn) d(e) nohr
estat ic

//Model 3
streg dist_nat_gap_civil dist_nat_gap_criminal litrate_1991_2001_GAP road_density_GAP lifeexp_1990_2011_GAP  percent_votes1991_1999_GAP cast_eth_fract ln_pop ln_abs_total2001 ///
if sample ==1, cluster(sn) d(e) nohr
estat ic

//Model 4
streg dist_nat_gap_civil dist_nat_gap_criminal litrate_1991_2001_GAP road_density_GAP lifeexp_1990_2011_GAP  percent_votes1991_1999_GAP  ln_pop ln_abs_total2001 ///
hilli_region mountain_region  if sample ==1, cluster(sn) d(e) nohr 
estat ic

//Model 5
streg dist_nat_gap_civil dist_nat_gap_criminal litrate_1991_2001_GAP road_density_GAP lifeexp_1990_2011_GAP  percent_votes1991_1999_GAP  ln_pop ln_abs_total2001 ///
 region_east region_mid region_west region_farwest  if sample ==1, cluster(sn) d(e) nohr
 estat ic
 
  //Model 6
 streg dist_nat_gap_civil dist_nat_gap_criminal litrate_1991_2001_GAP road_density_GAP lifeexp_1990_2011_GAP  percent_votes1991_1999_GAP  ln_pop ln_abs_total2001 	///
cast_eth_fract region_east region_mid region_west region_farwest hilli_region mountain_region if sample ==1, cluster(sn) d(e) nohr   

 
 
 //Endogeneity Test
 
xtreg dist_nat_gap_civil litrate_1991_2001_GAP road_density_GAP lifeexp_1990_2011_GAP percent_votes1991_1999_GAP hilli_region mountain_region if year<2007 & sample==1, vce(robust)
vif, uncen

xtreg dist_nat_gap_criminal litrate_1991_2001_GAP road_density_GAP lifeexp_1990_2011_GAP percent_votes1991_1999_GAP hilli_region mountain_region if year<2007 & sample==1, vce(robust)
vif, uncen


log close
 